package cn.wolfcode.car.business.web.controller.system;


import cn.wolfcode.car.base.service.IUserService;
import cn.wolfcode.car.business.domain.BpmnInfo;
import cn.wolfcode.car.business.domain.Leave;
import cn.wolfcode.car.business.domain.ServiceItemAuditVO;
import cn.wolfcode.car.business.query.LeaveQuery;
import cn.wolfcode.car.business.service.IBpmnInfoService;
import cn.wolfcode.car.business.service.ILeaveService;
import cn.wolfcode.car.common.base.page.TablePageInfo;
import cn.wolfcode.car.common.web.AjaxResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * 客户控制器
 */
@Controller
@RequestMapping("/business/leave")
public class LeaveController {
    //模板前缀
    private static final String prefix = "business/leave/";
    @Autowired
    private ILeaveService leaveService;
    @Autowired
private IUserService userService;
    @Autowired
    private IBpmnInfoService bpmnInfoService;
    //页面------------------------------------------------------------
    //列表
    @RequestMapping("/listPage")
    public String listPage(){
        return prefix + "list";
    }

    @RequestMapping("/startAuditPage")
    public String startAuditPage(Model model){

        //部门经理
        model.addAttribute("directors", userService.queryByRoleKey("shopOwner"));
        //人事
        model.addAttribute("finances", userService.queryByRoleKey("financial"));
        //流程
        BpmnInfo bpmnInfo = bpmnInfoService.queryByType("sick-leave");

        model.addAttribute("bpmnInfo",bpmnInfo);

        return  "business/leave/apply";
    }

    @RequestMapping("/startAudit")
    @ResponseBody
    public AjaxResult startAudit(ServiceItemAuditVO vo,Leave leave){
        leaveService.startAudit(vo,leave);
        return AjaxResult.success();
    }
    //数据-----------------------------------------------------------
    //列表
    @RequestMapping("/query")
    @ResponseBody
    public TablePageInfo<Leave> query(LeaveQuery qo){

        return leaveService.query(qo);
    }



}
